﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace InSafetyAirClient.GUI.PlaneModel
{
    public partial class ListPM : UserControl
    {

        List<InSafetyAirClient.InSafetyAirService.PlaneModel> models = null;
        AutoCompleteStringCollection autoComplete = new AutoCompleteStringCollection();
        public ListPM()
        {
            InitializeComponent();
        }

        private void ListPM_Load(object sender, EventArgs e)
        {
            if (!this.DesignMode)
            {
                populateList();
            }
        }

        private void populateList()
        {
            DataTable dataTable1 = new DataTable();
            dataTable1.Columns.Add("Plane Model", typeof(string));
            dataTable1.Columns.Add("Seats", typeof(string));
            ServiceSingle servS = ServiceSingle.Instance;
            models = servS.getService().GetAll(typeof(InSafetyAirClient.InSafetyAirService.PlaneModel).Name).OfType<InSafetyAirClient.InSafetyAirService.PlaneModel>().ToList();
            foreach (InSafetyAirService.PlaneModel planeM in models)
            {
                dataTable1.Rows.Add(planeM.planeModelName, planeM.seats);
            }
            dataGridView1.DataSource = dataTable1;
        }

    }
}
